/*
 *	IncomeStatementCSVParser.h
 *
 * 	Copyright (C) 2011 Aaron Huang
 * 	This file is part of StackPainter.
 *
 * 	StackPainter is free software: you can redistribute it and/or modify
 * 	it under the terms of the GNU General Public License as published by
 * 	the Free Software Foundation, either version 3 of the License, or
 * 	(at your option) any later version.
 *
 * 	StackPainter is distributed in the hope that it will be useful,
 * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 	GNU General Public License for more details.
 *
 * 	You should have received a copy of the GNU General Public License
 * 	along with StackPainter.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef INCOMESTATEMENTCSVPARSER_H_
#define INCOMESTATEMENTCSVPARSER_H_

#include <QMap>
#include <QList>
#include <QString>
#include <QFileInfoList>

class CompanyInfo;
class QFile;

class IncomeStatementCSVParser {
public:
	IncomeStatementCSVParser();

	virtual ~IncomeStatementCSVParser();

	void setDirPath(QString path);

	QList<CompanyInfo*> parse() throw(QString);

private:
	QFileInfoList getFileInfosByPath() throw(QString);

	void readLine(QFile& file, QString& aLine);

	void findFieldMap(QFile& file) throw(QString);

	void parseItems(int year, QFile& file);

	void parseFile(int year, const QString& fileName);

	QString _dirPath;
	QMap<int, CompanyInfo*> _companyInfos;
	QMap<QString, int> _fieldsMap;
};

#endif /* INCOMESTATEMENTCSVPARSER_H_ */
